<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>首页</title>
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="../../../css/bootstrap.min.css">
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="../../../js/jquery.min.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="../../../js/bootstrap.min.js"></script>
    <script src="../../../layui/layui.js"></script>
    <link rel="stylesheet" href="../../../layui/css/layui.css">

</head>

<body>
<div style="padding:0px; margin:0px;">
 <ul class="breadcrumb" style="  margin:0px; " >
    	<li><a href="#">系统管理</a></li>
        <li>权限管理</li>
    </ul>
</div>
<div class="row">
	<div class="col-sm-2"  style=" padding-left:30px;">
<!--        存储树节点-->
        <div id="anthory_tree"></div>
    </div>
    <div class="col-sm-10">
    	<iframe id="mainframe" name="mainiframe"  style="width:100%; border:0px; " ></iframe>
        <script type="text/javascript">
        	var height = jQuery(window).height()-50;
			jQuery("#mainframe").attr("height",height+"px");
        	jQuery("#mainframe").attr("src","anthorty_add.html");
        </script>
        
    </div>

</div>



<script>
    var tree;
    var update_anthorty;
    var select_tree_anthorty;

    layui.use('tree', function(){
        tree = layui.tree;
        var $ = layui.jquery;

        $("#mainframe").attr("src","anthorty_show.html")

        $.post("AnthortyInfoServlet.do?m=tree",function (data) {
            $("#mainframe")[0].contentWindow.initAnthorty(data.children[0]);
            //渲染
            initTree(data)
        },"json")

    });
    function flushTree6(pid) {
        //可以重载所有基础参数
        $.post("AnthortyInfoServlet.do?m=tree",function (data) {
            for (let i = 0; i < data.children.length; i++) {
                let a = data.children[i];
                console.log(a);
                if(a.anthortyId == pid){
                    a.spread = true;
                }
            }

            console.log(data);
            initTree(data);
        },"json")

    }

    function initTree(data) {
        tree.render({
            id:"an_tree",
            elem: '#anthory_tree'  //绑定元素
            ,accordion:true
            ,click: function(obj){
                // console.log(obj.data); //得到当前点击的节点数据
                // console.log(obj.state); //得到当前节点的展开状态：open、close、normal
                // console.log(obj.elem); //得到当前节点元素
                let innerWindow = $("#mainframe")[0].contentWindow;
                if(innerWindow.initAnthorty){
                    innerWindow.initAnthorty(obj.data);
                }else{
                    // console.log(obj.data.children); //当前节点下是否有子节点
                    select_tree_anthorty = obj.data;
                    $("#mainframe").attr("src","anthorty_show.html")
                }

            },
            text:{
                defaultNodeName:"未命名",
                none:"没有数据"
            }
            ,data: [data]
        });
    }



</script>

</body>
</html>
